package com.kungfuhacking.wristbandpro.find.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.base.view.BaseActivity;
import com.kungfuhacking.wristbandpro.base.view.HomeActivity;
import com.kungfuhacking.wristbandpro.custom.EnterItemView;
import com.kungfuhacking.wristbandpro.custom.TitleBarView;
import com.kungfuhacking.wristbandpro.find.presenter.ISubPresenter;
import com.kungfuhacking.wristbandpro.find.view.ISubView;

/**
 * 提交号码认证页面
 * Created by Aaron on 17/7/14.
 */

public class SubInfoActivity extends BaseActivity implements View.OnClickListener, ISubView {

    private String imei;
    private String phoneNum;
    private ISubPresenter iSubPresenter = new ISubPresenter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_sub_info);

        Bundle bundle = getIntent().getBundleExtra("bundle");

        imei = bundle.getString("imei");
        phoneNum = bundle.getString("phoneNum");

        initWidget();

    }

    private void initWidget() {

        EnterItemView eivImei = (EnterItemView) findViewById(R.id.eivImei);
        EnterItemView eivPhoneNum = (EnterItemView) findViewById(R.id.eivPhoneNum);
        TitleBarView tbv = (TitleBarView) findViewById(R.id.tbv);
        tbv.setOnLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                nextActivity(HomeActivity.class);
            }
        });
        TextView sub = (TextView) findViewById(R.id.sub);
        sub.setOnClickListener(this);

        eivImei.setRightTxt(imei);
        eivPhoneNum.setRightTxt(phoneNum);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case R.id.sub://确认
                iSubPresenter.sub(phoneNum);
                break;

        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        iSubPresenter.clearRequest();
    }

    @Override
    public void onBackPressed() {
        nextActivity(HomeActivity.class);
    }

}
